<template>
	<uni-card :title="title" :extra="type==='2'?'书籍':'帖子'" @click="goDetail">
		<image mode="aspectFit" :src="cover" style="width: 100%;height: 200rpx;"></image>
		<br>
		<view style="float: right;">
			<text class="uni-body">{{bookName}}</text>
		</view>
		
		<br>
		<text class="uni-body">{{desciption}}</text>
		<view>
		<view class="card-actions-item" @click="actionsClick('点赞')" v-if="likeCount!=null">
			<uni-icons type="heart" size="18" color="#999"></uni-icons>
			<text class="card-actions-item-text">点赞</text>
			<view style="margin-left: 15rpx;">
				<text >{{likeCount}}</text>
			</view>
		</view>
		<view class="card-actions-item" @click="actionsClick('评论')" style="margin-left: 20rpx;" v-if="commentCount!=null">
			<uni-icons type="chatbubble" size="18" color="#999"></uni-icons>
			<text class="card-actions-item-text">评论</text>
			<view style="margin-left: 15rpx;">
				<text >{{commentCount}}</text>
			</view>
		</view>
		</view>
		
	</uni-card>
</template>

<script setup>

import { ref } from 'vue';
	const props=defineProps({
		title:String,
		desciption:[Number,String],
		cover:String,
		type:String,
		likeCount:Number,
		commentCount:Number,
		id:Number,
		bookName:String
	})
	
	function goDetail(){
		console.log(props.id)
		if(props.type==1){
			uni.navigateTo({
				url:'/pages/detail/detail?id='+props.id
			})
		}
		
		else if(props.type==2){
			console.log(props.id)
			uni.navigateTo({
				url:'/pages/bookCategory/bookCategory?id='+props.id
			})
		}
	}
</script>

<style scoped>
.card-actions-item{
		float: left;
	}
</style>